package com.fhsk.file.business.entity.bo;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @author gaorui
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class PageLimitBo {

    @Min(value = 1, message = "页码至少为1")
    @NotNull(message = "页码不能为空")
    private Integer page;

    @Min(value = 1, message = "每页展示数量至少为1")
    @NotNull(message = "每页展示数量不能为空")
    private Integer limit;

    private Integer start;
    
    private String orderBy;

    public void setPage(Integer page) {
        this.page = page;
        if (this.limit != null) {
            this.start = (this.page - 1) * limit;
        }
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
        if (this.page != null) {
            this.start = (this.page - 1) * limit;
        }
    }
}
